/**
 * 交易对相关路由
 */

const express = require('express');
const router = express.Router();
const mysql = require('../services/mysql');

// 获取支持的交易对列表
router.get('/', async (req, res) => {
  try {
    const connection = await mysql.pool.getConnection();
    
    // 从数据库获取所有独特的交易对
    const [symbols] = await connection.query(
      `SELECT DISTINCT symbol FROM kline_1d_enhanced ORDER BY symbol`
    );
    
    connection.release();
    
    res.json({
      code: 200,
      success: true,
      message: '获取交易对列表成功',
      data: symbols.map(row => row.symbol)
    });
  } catch (error) {
    console.error('获取交易对列表失败:', error);
    res.status(500).json({
      code: 500,
      success: false,
      message: '获取交易对列表失败',
      error: error.message
    });
  }
});

module.exports = router; 